package com.wink.dt;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;

import com.google.gson.Gson;
import com.wink.common.Identity;

@XmlRootElement(name = "subjectentry")
@XmlAccessorType(XmlAccessType.FIELD)
public class Comment {
	
	@XmlElement(name = "comment")
	private String comment;
	
	@XmlElement(name = "topicName")
	private String topicName;	

	@XmlElement(name = "topicCommunityID")
	private String topicCommunityID;	

	@XmlElement(name = "identity")
	private Identity identity;	

	public String getComment() {
		return comment;
	}

	public void setComment(String comment) {
		this.comment = comment;
	}
	
	public String getTopicName() {
		return topicName;
	}

	public void setTopicName(String topicName) {
		this.topicName = topicName;
	}
	
	public String getTopicCommunityID() {
		return topicCommunityID;
	}

	public void setTopicCommunityID(String topicCommunityID) {
		this.topicCommunityID = topicCommunityID;
	}

	public Identity getIdentity() {
		return identity;
	}

	public void setIdentity(Identity identity) {
		this.identity = identity;
	}
	
	public String toString() {
		StringBuffer sf = new StringBuffer();
		
		sf.append("<comment> " + comment);
		sf.append("<identity> " + identity.toString());
				
		return sf.toString();
	}
	
	public static String toJson(Comment comment) {
		Gson gson = new Gson();
		String json = gson.toJson(comment, Comment.class);
		System.out.println("---> Comment: tojson  " + json);
		
		Comment retCh = gson.fromJson(json, Comment.class);
		return json;
	}
	
	public static Comment fromJson(String json) {
		Gson gson = new Gson();
		Comment retCh = gson.fromJson(json, Comment.class);
		//System.out.println("---> Comment: fromJson  " + retCh);
		return retCh;
	}

}
